﻿

//顶部底部菜单
function getZS_top(menu_str) {
    $.ajax({
        url: "ascx/top.html", type: "get", success: function (data) {
            $("#nav_site").html(data);
            $(menu_str).attr("class", "menu_a");
            getIsLogin();
        }
    });
    $.ajax({
        url: "ascx/footer.html", type: "get", success: function (data) {
            $(".footer").html(data);
        }
    });
}
function getZS_topNew(menu_str) {
    $.ajax({
        url: "/ascx/topNew.html", type: "get", success: function (data) {
            $("#header").html(data);
            $(menu_str).attr("class", "active");
            getIsLoginNew();
        }
    });
    $.ajax({
        url: "/ascx/footerNew.html", type: "get", success: function (data) {
            $("#footer").html(data);
        }
    });
}


//登录注册

function getIsLoginNew() {

    $.ajax({
        type: "post", url: "/app/get_zs_web.ashx",
        data: { "por": "101" },
        async: false, dataType: "json", success: function (data) {
            if (data.code == 1) {

                var topLoginHtml = '<li class="top-login"><a href="/perInfo.html">' + data.nickname + '</a><a class="top-login" href="/login.html">退出</a></li>';
                $('#top_menu').append($(topLoginHtml));


                //$("#zs_login").text(data.nickname).attr("href", "myProject.html");
                //$("#zs_reg").text("退出").attr("href", "login.html");

            } else {
                var topLoginHtml = '<li class="top-login"><a href="/register.html">注册</a><a class="btn-login " href="/login.html">登录</a></li>';
                $('#top_menu').append($(topLoginHtml));


            }
        }
    });
}

//登录注册

function getIsLogin() {

    $.ajax({
        type: "post", url: "/app/get_zs_web.ashx",
        data: { "por": "101"},
        async: false, dataType: "json", success: function (data) {
            if (data.code == 1) {
                $("#zs_login").text(data.nickname).attr("href", "myProject.html");
                $("#zs_reg").text("退出").attr("href", "login.html");

            } 
        }
    });
}
function getLogin_State() {
    var ss_login = 0;
    $.ajax({
        type: "post", url: "/app/get_zs_web.ashx",
        data: { "por": "101" },
        async: false, dataType: "json", success: function (data) {
            if (data.code == 1) {
                ss_login = 1;
            } 
        }
    });
    return ss_login;
}

function GetLinkUrl(url) { window.location.href = url; }
function GetLinkLogin() { window.location.href = "login.html"; }

function GetFormatDate(date_str)
{
    var date = new Date(date_str);
    var dStr = date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate();
    return dStr;
}

function GetUser_Info()//用户信息
{
    $.ajax({
        type: "post", url: "/app/get_zs_web.ashx",
        data: { "por": "106" },
        async: false, dataType: "json", success: function (data) {
            if (data.code == 1) {
                $("#my_data_imgurl").attr("src", data.img);
                $("#my_data_name").html(data.name);
                $("#my_data_point").html(data.point);
            }
        }
    });
}
function GetItemSearch() { var ssStr = $("#search").val(); if (ssStr.length > 0) { window.location.href = "proCenter.html?str=" + ssStr; } }


//计算时间大小
function dateCompare(startdate, enddate) {
    var arr = startdate.split("-");
    var starttime = new Date(arr[0], arr[1], arr[2]);
    var starttimes = starttime.getTime();

    var arrs = enddate.split("-");
    var lktime = new Date(arrs[0], arrs[1], arrs[2]);
    var lktimes = lktime.getTime();

    if (starttimes >= lktimes) {
        return false;
    }
    else
        return true;

}

